home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 018a / amac41.zip / DELSP11.QM < prev    next >
Text File  |  1991-07-29  |  11KB  |  263 lines

  1. *                              DELSP11.QM
  2. *               Macros To Delete Leading Spaces From Lines
  3. *                        Written by John Goodman
  4. *                             July 28, 1991
  5. * ================================================================
  6. *
  7. * The following macros may be used to delete leading spaces from
  8. * various lines in the file currently being edited.  The following
  9. * macros are provided:
  10. *                                                          -Bytes-
  11. *   @(1) Delete Leading Spaces from Current Line             (11)   |chg
  12. *   @(2) Delete Leading Spaces from Lines Delineated by Any  (22)
  13. *          Block (or Current Line if No Blocks Marked)
  14. *   @(3) Delete Leading Spaces from Current Paragraph        (15)
  15. *   @(4) Delete Leading Spaces from Current Paragraph and    (18)
  16. *          Reformat Paragraph to Right Margin
  17. *   @(5) Reformat Current Paragraph Ignoring AutoIndent Mode (20)
  18. *   @(6) Delete Leading Spaces from All Lines in File        (13)
  19. *   @(7) Delete Leading Spaces from All Lines in File and    (19)
  20. *          Reformat All Paragraphs to Right Margin
  21. *
  22. *   (@2 is probably the most versatile of the set)
  23. *
  24. * (Version) History
  25. *
  26. *-- eoi
  27.  
  28. * Each of the macros should operate correctly regardless of QConfig
  29. * or QEdit mode settings (Insert mode, WordWrap mode, etc.).  Most
  30. * of the macros work by creating a column block that is 2
  31. * characters wide at the beginning of each line from which leading
  32. * spaces are to be deleted.  When the "CenterLine" command is
  33. * executed, with the cursor in the 2-column block, QEdit tries to
  34. * center the line within the 2 columns.  This results in all
  35. * leading spaces being deleted from the line(s).
  36. *
  37. * Another excellent technique for deleting leading characters from
  38. * non-blank lines (i.e., test for a non-blank line first) is as
  39. * follows:
  40. *
  41. *       BegLine     * Go to 1st character of line
  42. *       ShiftRight  * Create at least 1 space at beginning of line
  43. *       DelRtWord   * DelRtWord deletes all space characters up
  44. *                   *   to the first non-blank character
  45. *                   *   (including "non-word" characters)
  46. *
  47. * Be aware that if lines other than the current line are blocked,
  48. * the ShiftRight command will shift all of them.  (Thanks to Tim
  49. * Farley of SemWare for the ideas behind this technique.)
  50.  
  51. * 
  52. * ---------------------------------------------
  53. * @(1) Delete Leading Spaces from Current Line
  54. * ---------------------------------------------
  55. * This macro deletes all space characters from the beginning of the
  56. * current line.  The cursor is positioned on the following line
  57. * after macro execution so that the macro can be invoked repeatedly
  58. * to delete the leading spaces from a series of lines.
  59. *
  60.  
  61. @1  MacroBegin
  62.     BegLine      * Go to beginning of line
  63.     SplitLine    * Split line at beginning
  64.     CursorRight  * Move to col 2
  65.     JoinLine     * Re-join the line
  66.     CursorLeft   * Move back to col 1
  67.     DelRtWord    * Delete leading spaces
  68.     CursorDown   * Move to next line to do again
  69. *
  70. * 12 bytes Tue  06-25-1991  15:13:57 (JG)
  71. * 11 bytes Sun  07-28-1991  17:21:41 (JG)
  72.  
  73. * 
  74. * ----------------------------------------------------------------
  75. * @(2) Delete Leading Spaces from Line(s) Delineated by any Block
  76. *      (or Current Line if no Blocks Marked)
  77. * ----------------------------------------------------------------
  78. * This macro will delete the space characters from the beginning of
  79. * each line that is bound by a block begin and end point.  Any type
  80. * of block (character, line, or column) may be used to delineate
  81. * the line(s) and only one block marker need be set. If no block
  82. * markers are set, the current line is acted upon.  The cursor will
  83. * be placed on the line following the last one acted upon so that
  84. * the macro can be invoked repeatedly to delete the leading spaces
  85. * from a series of lines.
  86. *
  87. @2  MacroBegin
  88.     CursorRight   * Needed for single line block
  89.     GotoBlockEnd  * Try going to block end, retain pos.
  90.  JTrue BLK:       * Determine if a completed block
  91.     DropAnchor    * If not, DropAnchor will finish it
  92.                   * or mark current line if none started
  93.     GotoBlockEnd  * Go to block end to retain position
  94.     MarkLine      * Mark first line
  95.  BLK:             * Line block now set
  96.     BegLine       * Go to begin of last line
  97.     GotoBlockBeg  * Go straight up to 1st line of block
  98.     MarkColumn    * Start column block
  99.     PrevPosition  * Return to last line of block
  100.     BegLine       * Make sure we're in col 1
  101.     CursorRight   * Move to column 2 (block now 2 cols)
  102.     CenterLine    * Centerline will now del leading spaces
  103.     UnmarkBlock   * Unmark the block
  104.     BegLine       * Go to begin of last line
  105.     CursorDown    * Move to next line to do again!
  106. *
  107. * 22 bytes Tue  06-25-1991  12:52:01 (JG)
  108.  
  109. * (THH added from QEdit docs, June 25, 1991)...
  110. *   [CenterLine]                  <^CL>
  111. *   ────────────────────────────────────────────────────────────────────
  112. *   If the cursor is inside a column block, the lines encompassed by the
  113. *   block are centered using the left and right columns of the block as
  114. *   the margins.
  115. *
  116. *   If the cursor is inside a line block, the lines encompassed by the
  117. *   block are centered using column 1 and the right margin as the margins.
  118. *
  119. *   Otherwise, the line the cursor is on is centered, using column 1 and
  120. *   the right margin as the margins.
  121.  
  122. * 
  123. * --------------------------------------------------
  124. * @(3) Delete Leading Spaces from Current Paragraph
  125. * --------------------------------------------------
  126. * This macro deletes all space characters from the beginning of the
  127. * lines in the paragraph in which the cursor is currently
  128. * positioned.  If the cursor is on a blank line (not in a
  129. * paragraph), then the previous paragraph will be acted upon.  The
  130. * cursor will be positioned at the beginning of the next paragraph
  131. * after macro execution so that the macro can be invoked repeatedly
  132. * to format a series of paragraphs.
  133. *
  134. @3  MacroBegin
  135.     UnmarkBlock    * Ensure no blocks marked
  136.     CursorDown     * Move down one line
  137.     PrevPara       * Go to begin of curr para
  138.     BegLine        * Start in col 1
  139.     MarkColumn     * Start Column block
  140.     EndPara        * Go to last line of para
  141.     BegLine        * Go to line begin
  142.     CursorRight    * Create 2 column block
  143.     CenterLine     * Centerline dels leading spaces
  144.     UnmarkBlock    * Unmark the block
  145.     NextPara       * Move to next para to do again!
  146. *
  147. * 15 bytes Tue  06-25-1991  16:28:15 (JG)
  148.  
  149. * 
  150. * ------------------------------------------------------
  151. * @(4) Delete Leading Spaces from Current Paragraph and
  152. *      Reformat Paragraph to Right Margin
  153. * ------------------------------------------------------
  154. * This macro deletes all space characters from the beginning of the
  155. * lines in the paragraph in which the cursor is currently
  156. * positioned and reformats (wordwraps) the paragraph at the
  157. * currently defined right margin.  If the cursor is on a blank line
  158. * (not in a paragraph), then the previous paragraph will be acted
  159. * upon.  The cursor will be positioned at the beginning of the next
  160. * paragraph after macro execution so that the macro can be invoked
  161. * repeatedly to format a series of paragraphs.
  162. *
  163. @4  MacroBegin
  164.     UnmarkBlock    * Ensure no blocks marked
  165.     CursorDown     * Move down one line
  166.     PrevPara       * Go to begin of curr para
  167.     BegLine        * Start in col 1
  168.     MarkColumn     * Start Column block
  169.     EndPara        * Go to last line of para
  170.     BegLine        * Go to line begin
  171.     CursorRight    * Create 2 column block
  172.     CenterLine     * Centerline dels leading spaces
  173.     UnmarkBlock    * Unmark the block
  174.     CursorDown
  175.     PrevPara
  176.     WrapPara
  177.     NextPara       * Move to next para to do again!
  178. *
  179. * 18 bytes Tue  06-25-1991  16:36:50  (JG)
  180.  
  181. * 
  182. * ---------------------------------------------------------
  183. * @(5) Reformat Current Paragraph Ignoring AutoIndent Mode
  184. * ---------------------------------------------------------
  185. * The following macro will reformat (wordwrap) the paragraph in
  186. * which the cursor is currently placed (or the previous paragraph
  187. * if the cursor is on a blank line) and will ignore AutoIndent mode
  188. * if it is set to ON.  The 1st line of the paragraph will retain
  189. * its indentation; the 2nd and subsequent lines will be left
  190. * justified to column 1 (as if AutoIndent were OFF).
  191. *
  192. @5  MacroBegin
  193.     UnmarkBlock         * Ensure no blocks marked
  194.     CursorDown PrevPara * Move to 1st line of current para
  195.     WrapPara PrevPara   * Wrap the para and return to 1st line
  196.     CursorDown          * Move to 2nd line of para
  197.     EndLine BegLine     * Test if there is a 2nd line
  198.  JFalse END:            * Skip if no 2nd line
  199.     ShiftRight          * Create space at front of line
  200.     DelRtWord           * Remove leading spaces
  201.     CursorUp            * Move back to 1st line of para
  202.     WrapPara            * Re-wrap the para
  203.  END:
  204.     NextPara            * Move to next para to do again!
  205. *
  206. * 20 bytes Tue  06-25-1991  15:43:06 (JG)
  207.  
  208. * 
  209. * --------------------------------------------------
  210. * @(6) Delete Leading Spaces from All Lines in File
  211. * --------------------------------------------------
  212. * This macro deletes all space characters from the beginning of
  213. * each line in the file currently being edited.
  214. *
  215. @6  MacroBegin
  216.     UnmarkBlock    * Ensure no blocks marked
  217.     EndFile        * Go to last line of file
  218.     BegLine        * Move to column 1
  219.     MarkColumn     * Start Column Block
  220.     BegFile        * Go to begin of file
  221.     CursorRight    * Create 2 column block
  222.     CenterLine     * Centerline will del leading spaces
  223.     UnmarkBlock    * Unmark the block
  224.     BegLine        * Return to file begin
  225. *
  226. * 13 bytes Tue  06-25-1991  15:04:05 (JG)
  227.  
  228. * 
  229. * ---------------------------------------------------------------
  230. * @(7) Delete Leading Spaces from All Lines in File and Reformat
  231. *      All Paragraphs to Right Margin
  232. * ---------------------------------------------------------------
  233. * This macro deletes all space characters from the beginning of
  234. * each line in the file currently being edited and reformats
  235. * (wordwraps) all paragraphs to the currently defined right margin
  236. * setting.
  237. *
  238. @7  MacroBegin
  239.     UnmarkBlock    * Ensure no blocks marked
  240.     EndFile        * Go to last line of file
  241.     BegLine        * Move to column 1
  242.     MarkColumn     * Start Column Block
  243.     BegFile        * Go to begin of file
  244.     CursorRight    * Create 2 column block
  245.     CenterLine     * Centerline will del leading spaces
  246.     UnmarkBlock    * Unmark the block
  247.     BegLine        * Return to file begin
  248.  WRAPLOOP:         * Loop for each para in file
  249.     WrapPara       * Wrap the para
  250.     CursorDown     * Try moving down 1 line
  251.  JTrue WRAPLOOP:   * Can't move down if at EOF
  252.     BegFile        * Return to begin of file
  253. *
  254. * 19 bytes Tue  06-25-1991  15:03:29 (JG)
  255.  
  256. * (Version) History
  257. * -----------------
  258. *   July 28, 1991   1.1   - Minor documentation change by TH.
  259. *                         - Shortened @1 one byte.
  260. *
  261. *
  262. *
  263.